// 189.轮转数组
package Leetcode_Second_Brush;

public class Solution189 {
    public void rotate(int[] nums, int k) {
        int length = nums.length;

        if (k % length == 0)
            return;

        int nums0 = nums[0];

        int index = 0;
        for (int i = 0; i < length - 1; i++) {
            nums[index] = nums[(index + length - k) % length];
            index = (index + length - k) % length;
        }

        nums[index] = nums0;
    }
}
